package org.bingo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bingo.constant.HttpStatus;

import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ReturnInfo {

    /*
    * 状态码
    * */
    private int code;
    /*
    * 状态码信息
    * */
    private String codeInfo;
    /*
    * 数据
    * */
    private Map<String,Object> data;



    /*
     * 访问成功
     * */
    public static ReturnInfo success(int code){
        return new ReturnInfo(code,"访问成功！",null);
    }

    public static ReturnInfo success(int code,String codeInfo){
        return new ReturnInfo(code,codeInfo,null);
    }

    public static ReturnInfo success(int code,Map<String,Object> data){
        return new ReturnInfo(code,"访问成功！",data);
    }

    public static ReturnInfo success(int code,String codeInfo,Map<String,Object> data){
        return new ReturnInfo(code,codeInfo,data);
    }

    public static ReturnInfo success(){
        return new ReturnInfo(HttpStatus.OK,"访问成功！",null);
    }

    /*
     * 访问失败
     * */
    public static ReturnInfo fail(int code){
        return new ReturnInfo(code,"访问失败！",null);
    }

    public static ReturnInfo fail(int code,String codeInfo){
        return new ReturnInfo(code,codeInfo,null);
    }

    public static ReturnInfo fail(int code,Map<String,Object> data){
        return new ReturnInfo(code,"访问失败！",data);
    }

    public static ReturnInfo fail(int code,String codeInfo,Map<String,Object> data){
        return new ReturnInfo(code,codeInfo,data);
    }



}
